/*
 *** Generated 22 Apr 2009 14:25:42 by Huagati DBML/EDMX Tools version 1.66.3395.29432
 *** Please read and verify the actions performed by this script before applying to your database. 
*/
/*Create schema */
create schema ;
go
/*Table dbo.AccountAnimals*/
Create Table dbo.AccountAnimals (AccountAnimalID int not null identity, AccountID int not null, AnimalID int not null,  constraint PK_AccountAnimals primary key (AccountAnimalID));
go
/*Table dbo.AccountPermissions*/
Create Table dbo.AccountPermissions (apid int not null identity, AccountID int not null, PermissionID int not null, Timestamp timestamp not null,  constraint PK_AccountPermissions primary key (apid));
go
/*Table dbo.Accounts*/
Create Table dbo.Accounts (AccountID int not null identity, Timestamp timestamp not null, CreateDate smalldatetime not null, UpdateDate smalldatetime not null, Username varchar(20) not null, Password varchar(50) not null, SecretQuestion varchar(200) not null, SecretAnswer varchar(200) not null, FirstName varchar(30) not null, LastName varchar(30) not null, Zipcode varchar(50) not null, Email varchar(150) not null, HomePhone varchar(20), CellPhone varchar(20), WorkPhone varchar(20), EmailVerified bit, TermID int, VerificationKey uniqueidentifier, Website varchar(150), Birthdate smalldatetime,  constraint PK_Accounts primary key (AccountID));
go
/*Table dbo.AccountToAccountFilters*/
Create Table dbo.AccountToAccountFilters (FilterID bigint not null identity, AccountID int not null, AccountToFilterID int not null, FilterTypeID int not null, CreateDate smalldatetime not null,  constraint PK_AccountToAccountFilters primary key (FilterID));
go
/*Table dbo.AccountToAccountFilterTypes*/
Create Table dbo.AccountToAccountFilterTypes (FilterTypeID int not null identity, Name varchar(100) not null,  constraint PK_AccountToAccountFilterTypes primary key (FilterTypeID));
go
/*Table dbo.Alerts*/
Create Table dbo.Alerts (AlertID bigint not null identity, AccountID int not null, CreateDate datetime not null, Timestamp timestamp not null, AlertTypeID int not null, IsHidden bit not null, Message varchar(max) not null,  constraint PK_Alerts primary key (AlertID));
go
/*Table dbo.AlertTypes*/
Create Table dbo.AlertTypes (AlertTypeID int not null identity, Name varchar(50) not null,  constraint PK_AlertTypes primary key (AlertTypeID));
go
/*Table dbo.Animals*/
Create Table dbo.Animals (AnimalID int not null identity, CompanyID int not null, Name varchar(100) not null, BirthDate smalldatetime not null, AnimalTypeID int not null, Timestamp timestamp not null, CreateDate smalldatetime not null, LocationID bigint not null,  constraint PK_Animals primary key (AnimalID));
go
/*Table dbo.AnimalTypes*/
Create Table dbo.AnimalTypes (AnimalTypeID int not null identity, Name varchar(100) not null, Timestamp timestamp not null, CreateDate smalldatetime not null,  constraint PK_AnimalTypes primary key (AnimalTypeID));
go
/*Table dbo.CalendarPosts*/
Create Table dbo.CalendarPosts (CalendarPostID bigint not null, StartDate smalldatetime not null, EndDate smalldatetime not null, StartTime smalldatetime not null, EndTime smalldatetime not null, Subject varchar(200) not null, Body varchar(max) not null, AccountID int not null, CalendarPostTypeID int not null, CalendarReminderTypeID int not null,  constraint PK_CalendarPosts primary key (CalendarPostID));
go
/*Table dbo.CalendarPostTypes*/
Create Table dbo.CalendarPostTypes (CalendarPostTypeID int not null identity, Name varchar(50) not null,  constraint PK_CalendarPostTypes primary key (CalendarPostTypeID));
go
/*Table dbo.CalendarRecipients*/
Create Table dbo.CalendarRecipients (CalendarPostRecipientID bigint not null identity, AccountID int not null, CreateDate smalldatetime not null, IsApproved bit not null,  constraint PK_CalendarRecipients primary key (CalendarPostRecipientID));
go
/*Table dbo.CalendarReminderTypes*/
Create Table dbo.CalendarReminderTypes (CalendarReminderTypeID int not null identity, Name varchar(50) not null,  constraint PK_CalendarReminderTypes primary key (CalendarReminderTypeID));
go
/*Table dbo.Categories*/
Create Table dbo.Categories (CategoryID int not null identity, Name varchar(100) not null, CreateDate smalldatetime not null, SystemObjectID int not null, SortOrder int not null, IsTopLevel bit not null, AccountID int not null,  constraint PK_Categories primary key (CategoryID));
go
/*Table dbo.CategoryToCategories*/
Create Table dbo.CategoryToCategories (CategoryToCategoryID int not null identity, ParentCategoryID int not null, ChildCategoryID int not null, CreateDate smalldatetime not null, AccountID int not null,  constraint PK_CategoryToCategories primary key (CategoryToCategoryID));
go
/*Table dbo.ClassifiedImages*/
Create Table dbo.ClassifiedImages (ClassifiedImageID bigint not null identity, ImageName varchar(100) not null, ImageType char(5) not null, ImageSize int not null, CreateDate smalldatetime not null, SortOrder int not null, ClassifiedPostID bigint not null, AccountID int not null,  constraint PK_ClassifiedImages primary key (ClassifiedImageID));
go
/*Table dbo.ClassifiedPosts*/
Create Table dbo.ClassifiedPosts (ClassifiedPostID bigint not null, ClassifiedCategoryID bigint not null identity, URL varchar(200) not null, Street1 varchar(200) not null, Street2 varchar(200), City varchar(200) not null, State varchar(2) not null, Zip int not null, Price money, Subject varchar(200) not null, Post varchar(max) not null, CreateDate smalldatetime not null, PublishDate smalldatetime not null, AccountID int not null, IsPublished bit not null, IsApproved bit not null, VisitCount int not null,  constraint PK_ClassifiedPosts primary key (ClassifiedPostID));
go
/*Table dbo.ClassifiedToCategories*/
Create Table dbo.ClassifiedToCategories (ClassifiedToCategoryID bigint not null identity, CategoryID int not null, ClassifiedPostID bigint not null, AccountID int not null, CreateDate smalldatetime,  constraint PK_ClassifiedToCategories primary key (ClassifiedToCategoryID));
go
/*Table dbo.Comments*/
Create Table dbo.Comments (CommentID bigint not null identity, Timestamp timestamp not null, Body varchar(2000) not null, CreateDate smalldatetime not null, CommentByAccountID int not null, CommentByUsername varchar(250) not null, SystemObjectID int not null, SystemObjectRecordID bigint not null,  constraint PK_Comments primary key (CommentID));
go
/*Table dbo.Companies*/
Create Table dbo.Companies (CompanyID int not null identity, CreatedByAccountID int not null, Timestamp timestamp not null, CreateDate smalldatetime not null, UpdateDate smalldatetime not null, Name varchar(100) not null, WebsiteURL varchar(150), Email varchar(150), Phone1 varchar(20) not null, Phone2 varchar(20), CompanyTypeID int, ZipCode varchar(15), Address1 varchar(200), Address2 varchar(200), City varchar(30), State varchar(2), Country varchar(200), Latitude float, Longitude float,  constraint PK_Companies primary key (CompanyID));
go
/*Table dbo.CompanyAccounts*/
Create Table dbo.CompanyAccounts (CompanyAccountID int not null identity, CompanyID int not null, AccountID int not null, CompanyAccountTypeID int not null, CreateDate smalldatetime not null, IsSubscribed bit not null,  constraint PK_CompanyAccounts primary key (CompanyAccountID));
go
/*Table dbo.CompanyAccountTypes*/
Create Table dbo.CompanyAccountTypes (CompanyAccountTypeID int not null identity, Name varchar(30) not null,  constraint PK_CompanyAccountTypes primary key (CompanyAccountTypeID));
go
/*Table dbo.CompanyAnimalLocations*/
Create Table dbo.CompanyAnimalLocations (LocationID bigint not null identity, Name varchar(100) not null, CompanyID int not null, CreateDate smalldatetime not null, AccountID int not null,  constraint PK_CompanyAnimalLocations primary key (LocationID));
go
/*Table dbo.CompanyFeatures*/
Create Table dbo.CompanyFeatures (CompanyFeatureID int not null identity, CompanyFeatureTypeID int not null, CompanyID int not null, CreateDate smalldatetime not null, Quantity int not null, Price money, Notes varchar(250),  constraint PK_CompanyFeatures primary key (CompanyFeatureID));
go
/*Table dbo.CompanyFeatureTypes*/
Create Table dbo.CompanyFeatureTypes (CompanyFeatureTypeID int not null identity, Name varchar(30) not null, CompanyTypeID int not null,  constraint PK_CompanyFeatureTypes primary key (CompanyFeatureTypeID));
go
/*Table dbo.CompanyTypes*/
Create Table dbo.CompanyTypes (CompanyTypeID int not null identity, Name varchar(150) not null,  constraint PK_CompanyTypes primary key (CompanyTypeID));
go
/*Table dbo.ContentFilters*/
Create Table dbo.ContentFilters (ContentFilterID int not null identity, StringToFilter varchar(500) not null, ReplaceWith varchar(500) not null, AccountID int not null, CreateDate smalldatetime not null, TimeStamp timestamp not null,  constraint PK_ContentFilters primary key (ContentFilterID));
go
/*Table dbo.FriendInvitations*/
Create Table dbo.FriendInvitations (InvitationID int not null identity, AccountID int not null, Email varchar(200) not null, GUID uniqueidentifier not null, CreateDate smalldatetime not null, BecameAccountID int not null, Timestamp timestamp not null,  constraint PK_FriendInvitations primary key (InvitationID));
go
/*Table dbo.Friends*/
Create Table dbo.Friends (FriendID int not null identity, AccountID int not null, MyFriendsAccountID int not null, CreateDate smalldatetime not null, Timestamp timestamp not null,  constraint PK_Friends primary key (FriendID));
go
/*Table dbo.Gags*/
Create Table dbo.Gags (GagID bigint not null identity, AccountID int not null, AccountUsername varchar(200) not null, CreateDate smalldatetime not null, TimeStamp timestamp not null, Reason varchar(1000), GagUntilDate smalldatetime, GaggedByAccountID int not null,  constraint PK_Gags primary key (GagID));
go
/*Table dbo.HelpMessages*/
Create Table dbo.HelpMessages (HelpMessageID int not null identity, Title varchar(100) not null, Body varchar(1000) not null, HelpMessageTypeID int not null,  constraint PK_HelpMessages primary key (HelpMessageID));
go
/*Table dbo.HelpMessageTypes*/
Create Table dbo.HelpMessageTypes (HelpMessageTypeID int not null identity, Name varchar(100) not null,  constraint PK_HelpMessageTypes primary key (HelpMessageTypeID));
go
/*Table dbo.MailQueue_History*/
Create Table dbo.MailQueue_History (MailQueueID bigint not null identity, SerializedMailMessage varchar(max) not null, CreateDate smalldatetime not null, SendDate smalldatetime not null,  constraint PK_MailQueue_History primary key (MailQueueID));
go
/*Table dbo.MailQueue_Receiving*/
Create Table dbo.MailQueue_Receiving (MailQueueID bigint not null identity, SerializedMailMessage varchar(max) not null, CreateDate smalldatetime not null, SendDate smalldatetime not null,  constraint PK_MailQueue_Receiving primary key (MailQueueID));
go
/*Table dbo.MailQueue_Working*/
Create Table dbo.MailQueue_Working (MailQueueID bigint not null identity, SerializedMailMessage varchar(max) not null, CreateDate smalldatetime not null, SendDate smalldatetime not null,  constraint PK_MailQueue_Working primary key (MailQueueID));
go
/*Table dbo.MessageRecipients*/
Create Table dbo.MessageRecipients (MessageRecipientID bigint not null identity, AccountID int not null, CreateDate smalldatetime not null, MessageRecipientStatusTypeID int not null, MessageID bigint not null,  constraint PK_MessageRecipients primary key (MessageRecipientID));
go
/*Table dbo.MessageRecipientStatusTypes*/
Create Table dbo.MessageRecipientStatusTypes (MessageRecipientStatusTypeID int not null identity, Name varchar(500) not null,  constraint PK_MessageRecipientStatusTypes primary key (MessageRecipientStatusTypeID));
go
/*Table dbo.Messages*/
Create Table dbo.Messages (MessageID bigint not null identity, SentByAccountID int not null, CreateDate smalldatetime not null, ReadDate smalldatetime not null, MessageTypeID int not null, Subject varchar(250) not null, Body varchar(max) not null,  constraint PK_Messages primary key (MessageID));
go
/*Table dbo.MessageTypes*/
Create Table dbo.MessageTypes (MessageTypeID int not null, Name varchar(100) not null,  constraint PK_MessageTypes primary key (MessageTypeID));
go
/*Table dbo.Moderations*/
Create Table dbo.Moderations (ModerationID bigint not null identity, AccountID int, AccountUsername varchar(200), SystemObjectID int not null, SystemObjectRecordID bigint not null, TimeStamp timestamp not null, CreateDate smalldatetime not null, IsApproved bit, IsDenied bit, ActionByAccountID int, ActionByUsername varchar(200),  constraint PK_Moderations primary key (ModerationID));
go
/*Table dbo.Permissions*/
Create Table dbo.Permissions (PermissionID int not null identity, Name varchar(50), Timestamp timestamp not null,  constraint PK_Permissions primary key (PermissionID));
go
/*Table .PostalCodes*/
Create Table .PostalCodes (CountryName nvarchar(3) not null, PostalCode nvarchar(7) not null, PostalType nvarchar(1) not null, CityName nvarchar(64) not null, CityType nvarchar(1) not null, CountyName nvarchar(64) not null, CountyFIPS nvarchar(5) not null, ProvinceName nvarchar(64) not null, ProvinceAbbr nvarchar(2) not null, StateFIPS nvarchar(2) not null, MSACode nvarchar(4) not null, AreaCode nvarchar(16) not null, TimeZone nvarchar(16) not null, UTC nvarchar(4) not null, DST nvarchar(1) not null, Latitude float not null, Longitude float not null,  constraint PK_PostalCodes primary key (CountryName, PostalCode, PostalType, CityName, CityType, CountyName, CountyFIPS, ProvinceName, ProvinceAbbr, StateFIPS, MSACode, AreaCode, TimeZone, UTC, DST, Latitude, Longitude));
go
/*Table dbo.PrivacyFlags*/
Create Table dbo.PrivacyFlags (PrivacyFlagID int not null identity, PrivacyFlagTypeID int not null, ProfileID int not null, VisibilityLevelID int not null, TimeStamp timestamp not null, CreateDate smalldatetime not null,  constraint PK_PrivacyFlags primary key (PrivacyFlagID));
go
/*Table dbo.PrivacyFlagTypes*/
Create Table dbo.PrivacyFlagTypes (PrivacyFlagTypeID int not null identity, FieldName varchar(50) not null, TimeStamp timestamp not null, SortOrder int not null,  constraint PK_PrivacyFlagTypes primary key (PrivacyFlagTypeID));
go
/*Table dbo.Ratings*/
Create Table dbo.Ratings (RatingID bigint not null identity, Score int not null, CreatedByUsername varchar(250) not null, CreatedByAccountID int not null, Timestamp timestamp not null, CreateDate smalldatetime not null, SystemObjectID int not null, SystemObjectRecordID bigint not null, SystemObjectRatingOptionID int not null,  constraint PK_Ratings primary key (RatingID));
go
/*Table dbo.StatusUpdates*/
Create Table dbo.StatusUpdates (StatusUpdateID bigint not null identity, CreateDate smalldatetime not null, Status varchar(250), AccountID int, Timestamp timestamp not null,  constraint PK_StatusUpdates primary key (StatusUpdateID));
go
/*Table dbo.sysdiagrams*/
Create Table dbo.sysdiagrams (name nvarchar(128) not null, principal_id int not null, diagram_id int not null identity, version int, definition varbinary(max),  constraint PK_sysdiagrams primary key (diagram_id));
go
/*Table dbo.SystemObjectRatingOptions*/
Create Table dbo.SystemObjectRatingOptions (SystemObjectRatingOptionID int not null identity, Name varchar(250) not null, Description varchar(1500) not null, Timestamp timestamp not null, SystemObjectID int not null,  constraint PK_SystemObjectRatingOptions primary key (SystemObjectRatingOptionID));
go
/*Table dbo.SystemObjects*/
Create Table dbo.SystemObjects (SystemObjectID int not null identity, Timestamp timestamp not null, Name varchar(100) not null,  constraint PK_SystemObjects primary key (SystemObjectID));
go
/*Table dbo.SystemObjectTags*/
Create Table dbo.SystemObjectTags (SystemObjectTagID bigint not null identity, Timestamp timestamp not null, TagID bigint not null, SystemObjectRecordID bigint not null, SystemObjectID int not null, CreateDate smalldatetime not null, CreatedByAccountID int not null, CreatedByUsername varchar(250) not null,  constraint PK_SystemObjectTags primary key (SystemObjectTagID));
go
/*Table dbo.Tags*/
Create Table dbo.Tags (TagID bigint not null identity, Name varchar(200) not null, Count int not null, Timestamp timestamp not null, CreateDate smalldatetime not null,  constraint PK_Tags primary key (TagID));
go
/*Table dbo.Terms*/
Create Table dbo.Terms (TermID int not null identity, Terms varchar(max) not null, CreateDate smalldatetime not null, Timestamp timestamp not null,  constraint PK_Terms primary key (TermID));
go
/*Table dbo.Trails*/
Create Table dbo.Trails (TrailID int not null identity, Name varchar(200) not null, Zip int not null, Body varchar(max) not null, CreateDate smalldatetime not null, MapURL varchar(200) not null, TrailDifficultyID int not null, Distance int not null, AccountID int not null,  constraint PK_Trails primary key (TrailID));
go
/*Table dbo.TrailToCategories*/
Create Table dbo.TrailToCategories (TrailToCategoryID int not null identity, TrailID int not null, CategoryID int not null, AccountID int,  constraint PK_TrailToCategories primary key (TrailToCategoryID));
go
/*Table dbo.Videos*/
Create Table dbo.Videos (VideoID bigint not null identity, Subject varchar(500) not null, URL varchar(200) not null, AccountID int not null, CreateDate smalldatetime not null, HTML varchar(500) not null,  constraint PK_Videos primary key (VideoID));
go
/*Table dbo.VideoToCategories*/
Create Table dbo.VideoToCategories (VideoToCategoryID bigint not null identity, VideoID bigint not null, CategoryID int not null, AccountID int,  constraint PK_VideoToCategories primary key (VideoToCategoryID));
go
/*Supporting index for FK_AccountAnimals_Accounts*/
Create Index IX_AccountAnimalsAccountID on dbo.AccountAnimals (AccountID);
go
/*Supporting index for FK_AccountAnimals_Animals*/
Create Index IX_AccountAnimalsAnimalID on dbo.AccountAnimals (AnimalID);
go
/*Supporting index for FK_AccountPermissions_Accounts*/
Create Index IX_AccountPermissionsAccountID on dbo.AccountPermissions (AccountID);
go
/*Supporting index for FK_AccountToAccountFilters_Accounts*/
Create Index IX_AccountToAccountFiltersAccountID on dbo.AccountToAccountFilters (AccountID);
go
/*Supporting index for FK_AccountToAccountFilters_AccountToAccountFilterTypes*/
Create Index IX_AccountToAccountFiltersFilterTypeID on dbo.AccountToAccountFilters (FilterTypeID);
go
/*Supporting index for FK_Alerts_Accounts*/
Create Index IX_AlertsAccountID on dbo.Alerts (AccountID);
go
/*Supporting index for FK_Animals_AnimalTypes*/
Create Index IX_AnimalsAnimalTypeID on dbo.Animals (AnimalTypeID);
go
/*Supporting index for FK_Animals_Companies*/
Create Index IX_AnimalsCompanyID on dbo.Animals (CompanyID);
go
/*Supporting index for FK_Animals_CompanyAnimalLocations*/
Create Index IX_AnimalsLocationID on dbo.Animals (LocationID);
go
/*Supporting index for FK_CalendarPosts_Accounts*/
Create Index IX_CalendarPostsAccountID on dbo.CalendarPosts (AccountID);
go
/*Supporting index for FK_CalendarPosts_CalendarPostTypes*/
Create Index IX_CalendarPostsCalendarPostTypeID on dbo.CalendarPosts (CalendarPostTypeID);
go
/*Supporting index for FK_CalendarPosts_CalendarReminderTypes*/
Create Index IX_CalendarPostsCalendarReminderTypeID on dbo.CalendarPosts (CalendarReminderTypeID);
go
/*Supporting index for FK_CalendarRecipients_Accounts*/
Create Index IX_CalendarRecipientsAccountID on dbo.CalendarRecipients (AccountID);
go
/*Supporting index for FK_Categories_Accounts*/
Create Index IX_CategoriesAccountID on dbo.Categories (AccountID);
go
/*Supporting index for FK_CategoryToCategories_Accounts*/
Create Index IX_CategoryToCategoriesAccountID on dbo.CategoryToCategories (AccountID);
go
/*Supporting index for FK_CategoryToCategories_Categories*/
Create Index IX_CategoryToCategoriesParentCategoryID on dbo.CategoryToCategories (ParentCategoryID);
go
/*Supporting index for FK_CategoryToCategories_Categories1*/
Create Index IX_CategoryToCategoriesChildCategoryID on dbo.CategoryToCategories (ChildCategoryID);
go
/*Supporting index for FK_ClassifiedImages_Accounts*/
Create Index IX_ClassifiedImagesAccountID on dbo.ClassifiedImages (AccountID);
go
/*Supporting index for FK_ClassifiedImages_ClassifiedPosts*/
Create Index IX_ClassifiedImagesClassifiedPostID on dbo.ClassifiedImages (ClassifiedPostID);
go
/*Supporting index for FK_ClassifiedPosts_Accounts*/
Create Index IX_ClassifiedPostsAccountID on dbo.ClassifiedPosts (AccountID);
go
/*Supporting index for FK_ClassifiedToCategories_Accounts*/
Create Index IX_ClassifiedToCategoriesAccountID on dbo.ClassifiedToCategories (AccountID);
go
/*Supporting index for FK_ClassifiedToCategories_Categories*/
Create Index IX_ClassifiedToCategoriesCategoryID on dbo.ClassifiedToCategories (CategoryID);
go
/*Supporting index for FK_ClassifiedToCategories_ClassifiedPosts*/
Create Index IX_ClassifiedToCategoriesClassifiedPostID on dbo.ClassifiedToCategories (ClassifiedPostID);
go
/*Supporting index for FK_Comments_Accounts*/
Create Index IX_CommentsCommentByAccountID on dbo.Comments (CommentByAccountID);
go
/*Supporting index for FK_Comments_SystemObjects*/
Create Index IX_CommentsSystemObjectID on dbo.Comments (SystemObjectID);
go
/*Supporting index for FK_Companies_CompanyTypes*/
Create Index IX_CompaniesCompanyTypeID on dbo.Companies (CompanyTypeID);
go
/*Supporting index for FK_CompanyAccounts_Accounts*/
Create Index IX_CompanyAccountsAccountID on dbo.CompanyAccounts (AccountID);
go
/*Supporting index for FK_CompanyAccounts_Companies*/
Create Index IX_CompanyAccountsCompanyID on dbo.CompanyAccounts (CompanyID);
go
/*Supporting index for FK_CompanyAccounts_CompanyAccountTypes*/
Create Index IX_CompanyAccountsCompanyAccountTypeID on dbo.CompanyAccounts (CompanyAccountTypeID);
go
/*Supporting index for FK_CompanyAnimalLocations_Accounts*/
Create Index IX_CompanyAnimalLocationsAccountID on dbo.CompanyAnimalLocations (AccountID);
go
/*Supporting index for FK_CompanyAnimalLocations_Companies*/
Create Index IX_CompanyAnimalLocationsCompanyID on dbo.CompanyAnimalLocations (CompanyID);
go
/*Supporting index for FK_CompanyFeatures_Companies*/
Create Index IX_CompanyFeaturesCompanyID on dbo.CompanyFeatures (CompanyID);
go
/*Supporting index for FK_CompanyFeatures_CompanyFeatureTypes*/
Create Index IX_CompanyFeaturesCompanyFeatureTypeID on dbo.CompanyFeatures (CompanyFeatureTypeID);
go
/*Supporting index for FK_ContentFilters_Accounts*/
Create Index IX_ContentFiltersAccountID on dbo.ContentFilters (AccountID);
go
/*Supporting index for FK_FriendInvitations_Accounts*/
Create Index IX_FriendInvitationsAccountID on dbo.FriendInvitations (AccountID);
go
/*Supporting index for FK_Friends_Accounts*/
Create Index IX_FriendsAccountID on dbo.Friends (AccountID);
go
/*Supporting index for FK_Friends_Accounts1*/
Create Index IX_FriendsMyFriendsAccountID on dbo.Friends (MyFriendsAccountID);
go
/*Supporting index for FK_Gags_Accounts*/
Create Index IX_GagsAccountID on dbo.Gags (AccountID);
go
/*Supporting index for FK_Gags_Accounts1*/
Create Index IX_GagsGaggedByAccountID on dbo.Gags (GaggedByAccountID);
go
/*Supporting index for FK_HelpMessages_HelpMessageTypes*/
Create Index IX_HelpMessagesHelpMessageTypeID on dbo.HelpMessages (HelpMessageTypeID);
go
/*Supporting index for FK_MessageRecipients_MessageRecipientStatusTypes*/
Create Index IX_MessageRecipientsMessageRecipientStatusTypeID on dbo.MessageRecipients (MessageRecipientStatusTypeID);
go
/*Supporting index for FK_MessageRecipients_Messages*/
Create Index IX_MessageRecipientsMessageID on dbo.MessageRecipients (MessageID);
go
/*Supporting index for FK_Messages_Accounts*/
Create Index IX_MessagesSentByAccountID on dbo.Messages (SentByAccountID);
go
/*Supporting index for FK_Messages_MessageTypes*/
Create Index IX_MessagesMessageTypeID on dbo.Messages (MessageTypeID);
go
/*Supporting index for FK_Moderations_Accounts*/
Create Index IX_ModerationsAccountID on dbo.Moderations (AccountID);
go
/*Supporting index for FK_Moderations_SystemObjects*/
Create Index IX_ModerationsSystemObjectID on dbo.Moderations (SystemObjectID);
go
/*Supporting index for FK_PrivacyFlags_PrivacyFlagTypes*/
Create Index IX_PrivacyFlagsPrivacyFlagTypeID on dbo.PrivacyFlags (PrivacyFlagTypeID);
go
/*Supporting index for FK_Ratings_Accounts*/
Create Index IX_RatingsCreatedByAccountID on dbo.Ratings (CreatedByAccountID);
go
/*Supporting index for FK_Ratings_SystemObjectRatingOptions*/
Create Index IX_RatingsSystemObjectRatingOptionID on dbo.Ratings (SystemObjectRatingOptionID);
go
/*Supporting index for FK_Ratings_SystemObjects*/
Create Index IX_RatingsSystemObjectID on dbo.Ratings (SystemObjectID);
go
/*Supporting index for FK_StatusUpdates_Accounts*/
Create Index IX_StatusUpdatesAccountID on dbo.StatusUpdates (AccountID);
go
/*Supporting index for FK_SystemObjectRatingOptions_SystemObjects*/
Create Index IX_SystemObjectRatingOptionsSystemObjectID on dbo.SystemObjectRatingOptions (SystemObjectID);
go
/*Supporting index for FK_SystemObjectTags_Accounts*/
Create Index IX_SystemObjectTagsCreatedByAccountID on dbo.SystemObjectTags (CreatedByAccountID);
go
/*Supporting index for FK_SystemObjectTags_SystemObjects*/
Create Index IX_SystemObjectTagsSystemObjectID on dbo.SystemObjectTags (SystemObjectID);
go
/*Supporting index for FK_SystemObjectTags_Tags*/
Create Index IX_SystemObjectTagsTagID on dbo.SystemObjectTags (TagID);
go
/*Supporting index for FK_Trails_Accounts*/
Create Index IX_TrailsAccountID on dbo.Trails (AccountID);
go
/*Supporting index for FK_TrailToCategories_Accounts*/
Create Index IX_TrailToCategoriesAccountID on dbo.TrailToCategories (AccountID);
go
/*Supporting index for FK_TrailToCategories_Categories*/
Create Index IX_TrailToCategoriesCategoryID on dbo.TrailToCategories (CategoryID);
go
/*Supporting index for FK_TrailToCategories_Trails*/
Create Index IX_TrailToCategoriesTrailID on dbo.TrailToCategories (TrailID);
go
/*Supporting index for FK_Videos_Accounts*/
Create Index IX_VideosAccountID on dbo.Videos (AccountID);
go
/*Supporting index for FK_VideoToCategories_Accounts*/
Create Index IX_VideoToCategoriesAccountID on dbo.VideoToCategories (AccountID);
go
/*Supporting index for FK_VideoToCategories_Categories*/
Create Index IX_VideoToCategoriesCategoryID on dbo.VideoToCategories (CategoryID);
go
/*Supporting index for FK_VideoToCategories_Videos*/
Create Index IX_VideoToCategoriesVideoID on dbo.VideoToCategories (VideoID);
go
/*Foreign key FK_AccountAnimals_Accounts from dbo.AccountAnimals to dbo.Accounts*/
Alter Table dbo.AccountAnimals add constraint FK_AccountAnimals_Accounts foreign key (AccountID) references dbo.Accounts (AccountID);
go
/*Foreign key FK_AccountAnimals_Animals from dbo.AccountAnimals to dbo.Animals*/
Alter Table dbo.AccountAnimals add constraint FK_AccountAnimals_Animals foreign key (AnimalID) references dbo.Animals (AnimalID);
go
/*Foreign key FK_AccountPermissions_Accounts from dbo.AccountPermissions to dbo.Accounts*/
Alter Table dbo.AccountPermissions add constraint FK_AccountPermissions_Accounts foreign key (AccountID) references dbo.Accounts (AccountID);
go
/*Foreign key FK_AccountToAccountFilters_Accounts from dbo.AccountToAccountFilters to dbo.Accounts*/
Alter Table dbo.AccountToAccountFilters add constraint FK_AccountToAccountFilters_Accounts foreign key (AccountID) references dbo.Accounts (AccountID);
go
/*Foreign key FK_AccountToAccountFilters_AccountToAccountFilterTypes from dbo.AccountToAccountFilters to dbo.AccountToAccountFilterTypes*/
Alter Table dbo.AccountToAccountFilters add constraint FK_AccountToAccountFilters_AccountToAccountFilterTypes foreign key (FilterTypeID) references dbo.AccountToAccountFilterTypes (FilterTypeID);
go
/*Foreign key FK_Alerts_Accounts from dbo.Alerts to dbo.Accounts*/
Alter Table dbo.Alerts add constraint FK_Alerts_Accounts foreign key (AccountID) references dbo.Accounts (AccountID);
go
/*Foreign key FK_Animals_AnimalTypes from dbo.Animals to dbo.AnimalTypes*/
Alter Table dbo.Animals add constraint FK_Animals_AnimalTypes foreign key (AnimalTypeID) references dbo.AnimalTypes (AnimalTypeID);
go
/*Foreign key FK_Animals_Companies from dbo.Animals to dbo.Companies*/
Alter Table dbo.Animals add constraint FK_Animals_Companies foreign key (CompanyID) references dbo.Companies (CompanyID);
go
/*Foreign key FK_Animals_CompanyAnimalLocations from dbo.Animals to dbo.CompanyAnimalLocations*/
Alter Table dbo.Animals add constraint FK_Animals_CompanyAnimalLocations foreign key (LocationID) references dbo.CompanyAnimalLocations (LocationID);
go
/*Foreign key FK_CalendarPosts_Accounts from dbo.CalendarPosts to dbo.Accounts*/
Alter Table dbo.CalendarPosts add constraint FK_CalendarPosts_Accounts foreign key (AccountID) references dbo.Accounts (AccountID);
go
/*Foreign key FK_CalendarPosts_CalendarPostTypes from dbo.CalendarPosts to dbo.CalendarPostTypes*/
Alter Table dbo.CalendarPosts add constraint FK_CalendarPosts_CalendarPostTypes foreign key (CalendarPostTypeID) references dbo.CalendarPostTypes (CalendarPostTypeID);
go
/*Foreign key FK_CalendarPosts_CalendarReminderTypes from dbo.CalendarPosts to dbo.CalendarReminderTypes*/
Alter Table dbo.CalendarPosts add constraint FK_CalendarPosts_CalendarReminderTypes foreign key (CalendarReminderTypeID) references dbo.CalendarReminderTypes (CalendarReminderTypeID);
go
/*Foreign key FK_CalendarRecipients_Accounts from dbo.CalendarRecipients to dbo.Accounts*/
Alter Table dbo.CalendarRecipients add constraint FK_CalendarRecipients_Accounts foreign key (AccountID) references dbo.Accounts (AccountID);
go
/*Foreign key FK_Categories_Accounts from dbo.Categories to dbo.Accounts*/
Alter Table dbo.Categories add constraint FK_Categories_Accounts foreign key (AccountID) references dbo.Accounts (AccountID);
go
/*Foreign key FK_CategoryToCategories_Accounts from dbo.CategoryToCategories to dbo.Accounts*/
Alter Table dbo.CategoryToCategories add constraint FK_CategoryToCategories_Accounts foreign key (AccountID) references dbo.Accounts (AccountID);
go
/*Foreign key FK_CategoryToCategories_Categories from dbo.CategoryToCategories to dbo.Categories*/
Alter Table dbo.CategoryToCategories add constraint FK_CategoryToCategories_Categories foreign key (ParentCategoryID) references dbo.Categories (CategoryID);
go
/*Foreign key FK_CategoryToCategories_Categories1 from dbo.CategoryToCategories to dbo.Categories*/
Alter Table dbo.CategoryToCategories add constraint FK_CategoryToCategories_Categories1 foreign key (ChildCategoryID) references dbo.Categories (CategoryID);
go
/*Foreign key FK_ClassifiedImages_Accounts from dbo.ClassifiedImages to dbo.Accounts*/
Alter Table dbo.ClassifiedImages add constraint FK_ClassifiedImages_Accounts foreign key (AccountID) references dbo.Accounts (AccountID);
go
/*Foreign key FK_ClassifiedImages_ClassifiedPosts from dbo.ClassifiedImages to dbo.ClassifiedPosts*/
Alter Table dbo.ClassifiedImages add constraint FK_ClassifiedImages_ClassifiedPosts foreign key (ClassifiedPostID) references dbo.ClassifiedPosts (ClassifiedPostID);
go
/*Foreign key FK_ClassifiedPosts_Accounts from dbo.ClassifiedPosts to dbo.Accounts*/
Alter Table dbo.ClassifiedPosts add constraint FK_ClassifiedPosts_Accounts foreign key (AccountID) references dbo.Accounts (AccountID);
go
/*Foreign key FK_ClassifiedToCategories_Accounts from dbo.ClassifiedToCategories to dbo.Accounts*/
Alter Table dbo.ClassifiedToCategories add constraint FK_ClassifiedToCategories_Accounts foreign key (AccountID) references dbo.Accounts (AccountID);
go
/*Foreign key FK_ClassifiedToCategories_Categories from dbo.ClassifiedToCategories to dbo.Categories*/
Alter Table dbo.ClassifiedToCategories add constraint FK_ClassifiedToCategories_Categories foreign key (CategoryID) references dbo.Categories (CategoryID);
go
/*Foreign key FK_ClassifiedToCategories_ClassifiedPosts from dbo.ClassifiedToCategories to dbo.ClassifiedPosts*/
Alter Table dbo.ClassifiedToCategories add constraint FK_ClassifiedToCategories_ClassifiedPosts foreign key (ClassifiedPostID) references dbo.ClassifiedPosts (ClassifiedPostID);
go
/*Foreign key FK_Comments_Accounts from dbo.Comments to dbo.Accounts*/
Alter Table dbo.Comments add constraint FK_Comments_Accounts foreign key (CommentByAccountID) references dbo.Accounts (AccountID);
go
/*Foreign key FK_Comments_SystemObjects from dbo.Comments to dbo.SystemObjects*/
Alter Table dbo.Comments add constraint FK_Comments_SystemObjects foreign key (SystemObjectID) references dbo.SystemObjects (SystemObjectID);
go
/*Foreign key FK_Companies_CompanyTypes from dbo.Companies to dbo.CompanyTypes*/
Alter Table dbo.Companies add constraint FK_Companies_CompanyTypes foreign key (CompanyTypeID) references dbo.CompanyTypes (CompanyTypeID);
go
/*Foreign key FK_CompanyAccounts_Accounts from dbo.CompanyAccounts to dbo.Accounts*/
Alter Table dbo.CompanyAccounts add constraint FK_CompanyAccounts_Accounts foreign key (AccountID) references dbo.Accounts (AccountID);
go
/*Foreign key FK_CompanyAccounts_Companies from dbo.CompanyAccounts to dbo.Companies*/
Alter Table dbo.CompanyAccounts add constraint FK_CompanyAccounts_Companies foreign key (CompanyID) references dbo.Companies (CompanyID);
go
/*Foreign key FK_CompanyAccounts_CompanyAccountTypes from dbo.CompanyAccounts to dbo.CompanyAccountTypes*/
Alter Table dbo.CompanyAccounts add constraint FK_CompanyAccounts_CompanyAccountTypes foreign key (CompanyAccountTypeID) references dbo.CompanyAccountTypes (CompanyAccountTypeID);
go
/*Foreign key FK_CompanyAnimalLocations_Accounts from dbo.CompanyAnimalLocations to dbo.Accounts*/
Alter Table dbo.CompanyAnimalLocations add constraint FK_CompanyAnimalLocations_Accounts foreign key (AccountID) references dbo.Accounts (AccountID);
go
/*Foreign key FK_CompanyAnimalLocations_Companies from dbo.CompanyAnimalLocations to dbo.Companies*/
Alter Table dbo.CompanyAnimalLocations add constraint FK_CompanyAnimalLocations_Companies foreign key (CompanyID) references dbo.Companies (CompanyID);
go
/*Foreign key FK_CompanyFeatures_Companies from dbo.CompanyFeatures to dbo.Companies*/
Alter Table dbo.CompanyFeatures add constraint FK_CompanyFeatures_Companies foreign key (CompanyID) references dbo.Companies (CompanyID);
go
/*Foreign key FK_CompanyFeatures_CompanyFeatureTypes from dbo.CompanyFeatures to dbo.CompanyFeatureTypes*/
Alter Table dbo.CompanyFeatures add constraint FK_CompanyFeatures_CompanyFeatureTypes foreign key (CompanyFeatureTypeID) references dbo.CompanyFeatureTypes (CompanyFeatureTypeID);
go
/*Foreign key FK_ContentFilters_Accounts from dbo.ContentFilters to dbo.Accounts*/
Alter Table dbo.ContentFilters add constraint FK_ContentFilters_Accounts foreign key (AccountID) references dbo.Accounts (AccountID);
go
/*Foreign key FK_FriendInvitations_Accounts from dbo.FriendInvitations to dbo.Accounts*/
Alter Table dbo.FriendInvitations add constraint FK_FriendInvitations_Accounts foreign key (AccountID) references dbo.Accounts (AccountID);
go
/*Foreign key FK_Friends_Accounts from dbo.Friends to dbo.Accounts*/
Alter Table dbo.Friends add constraint FK_Friends_Accounts foreign key (AccountID) references dbo.Accounts (AccountID);
go
/*Foreign key FK_Friends_Accounts1 from dbo.Friends to dbo.Accounts*/
Alter Table dbo.Friends add constraint FK_Friends_Accounts1 foreign key (MyFriendsAccountID) references dbo.Accounts (AccountID);
go
/*Foreign key FK_Gags_Accounts from dbo.Gags to dbo.Accounts*/
Alter Table dbo.Gags add constraint FK_Gags_Accounts foreign key (AccountID) references dbo.Accounts (AccountID);
go
/*Foreign key FK_Gags_Accounts1 from dbo.Gags to dbo.Accounts*/
Alter Table dbo.Gags add constraint FK_Gags_Accounts1 foreign key (GaggedByAccountID) references dbo.Accounts (AccountID);
go
/*Foreign key FK_HelpMessages_HelpMessageTypes from dbo.HelpMessages to dbo.HelpMessageTypes*/
Alter Table dbo.HelpMessages add constraint FK_HelpMessages_HelpMessageTypes foreign key (HelpMessageTypeID) references dbo.HelpMessageTypes (HelpMessageTypeID);
go
/*Foreign key FK_MessageRecipients_MessageRecipientStatusTypes from dbo.MessageRecipients to dbo.MessageRecipientStatusTypes*/
Alter Table dbo.MessageRecipients add constraint FK_MessageRecipients_MessageRecipientStatusTypes foreign key (MessageRecipientStatusTypeID) references dbo.MessageRecipientStatusTypes (MessageRecipientStatusTypeID);
go
/*Foreign key FK_MessageRecipients_Messages from dbo.MessageRecipients to dbo.Messages*/
Alter Table dbo.MessageRecipients add constraint FK_MessageRecipients_Messages foreign key (MessageID) references dbo.Messages (MessageID);
go
/*Foreign key FK_Messages_Accounts from dbo.Messages to dbo.Accounts*/
Alter Table dbo.Messages add constraint FK_Messages_Accounts foreign key (SentByAccountID) references dbo.Accounts (AccountID);
go
/*Foreign key FK_Messages_MessageTypes from dbo.Messages to dbo.MessageTypes*/
Alter Table dbo.Messages add constraint FK_Messages_MessageTypes foreign key (MessageTypeID) references dbo.MessageTypes (MessageTypeID);
go
/*Foreign key FK_Moderations_Accounts from dbo.Moderations to dbo.Accounts*/
Alter Table dbo.Moderations add constraint FK_Moderations_Accounts foreign key (AccountID) references dbo.Accounts (AccountID);
go
/*Foreign key FK_Moderations_SystemObjects from dbo.Moderations to dbo.SystemObjects*/
Alter Table dbo.Moderations add constraint FK_Moderations_SystemObjects foreign key (SystemObjectID) references dbo.SystemObjects (SystemObjectID);
go
/*Foreign key FK_PrivacyFlags_PrivacyFlagTypes from dbo.PrivacyFlags to dbo.PrivacyFlagTypes*/
Alter Table dbo.PrivacyFlags add constraint FK_PrivacyFlags_PrivacyFlagTypes foreign key (PrivacyFlagTypeID) references dbo.PrivacyFlagTypes (PrivacyFlagTypeID);
go
/*Foreign key FK_Ratings_Accounts from dbo.Ratings to dbo.Accounts*/
Alter Table dbo.Ratings add constraint FK_Ratings_Accounts foreign key (CreatedByAccountID) references dbo.Accounts (AccountID);
go
/*Foreign key FK_Ratings_SystemObjectRatingOptions from dbo.Ratings to dbo.SystemObjectRatingOptions*/
Alter Table dbo.Ratings add constraint FK_Ratings_SystemObjectRatingOptions foreign key (SystemObjectRatingOptionID) references dbo.SystemObjectRatingOptions (SystemObjectRatingOptionID);
go
/*Foreign key FK_Ratings_SystemObjects from dbo.Ratings to dbo.SystemObjects*/
Alter Table dbo.Ratings add constraint FK_Ratings_SystemObjects foreign key (SystemObjectID) references dbo.SystemObjects (SystemObjectID);
go
/*Foreign key FK_StatusUpdates_Accounts from dbo.StatusUpdates to dbo.Accounts*/
Alter Table dbo.StatusUpdates add constraint FK_StatusUpdates_Accounts foreign key (AccountID) references dbo.Accounts (AccountID);
go
/*Foreign key FK_SystemObjectRatingOptions_SystemObjects from dbo.SystemObjectRatingOptions to dbo.SystemObjects*/
Alter Table dbo.SystemObjectRatingOptions add constraint FK_SystemObjectRatingOptions_SystemObjects foreign key (SystemObjectID) references dbo.SystemObjects (SystemObjectID);
go
/*Foreign key FK_SystemObjectTags_Accounts from dbo.SystemObjectTags to dbo.Accounts*/
Alter Table dbo.SystemObjectTags add constraint FK_SystemObjectTags_Accounts foreign key (CreatedByAccountID) references dbo.Accounts (AccountID);
go
/*Foreign key FK_SystemObjectTags_SystemObjects from dbo.SystemObjectTags to dbo.SystemObjects*/
Alter Table dbo.SystemObjectTags add constraint FK_SystemObjectTags_SystemObjects foreign key (SystemObjectID) references dbo.SystemObjects (SystemObjectID);
go
/*Foreign key FK_SystemObjectTags_Tags from dbo.SystemObjectTags to dbo.Tags*/
Alter Table dbo.SystemObjectTags add constraint FK_SystemObjectTags_Tags foreign key (TagID) references dbo.Tags (TagID);
go
/*Foreign key FK_Trails_Accounts from dbo.Trails to dbo.Accounts*/
Alter Table dbo.Trails add constraint FK_Trails_Accounts foreign key (AccountID) references dbo.Accounts (AccountID);
go
/*Foreign key FK_TrailToCategories_Accounts from dbo.TrailToCategories to dbo.Accounts*/
Alter Table dbo.TrailToCategories add constraint FK_TrailToCategories_Accounts foreign key (AccountID) references dbo.Accounts (AccountID);
go
/*Foreign key FK_TrailToCategories_Categories from dbo.TrailToCategories to dbo.Categories*/
Alter Table dbo.TrailToCategories add constraint FK_TrailToCategories_Categories foreign key (CategoryID) references dbo.Categories (CategoryID);
go
/*Foreign key FK_TrailToCategories_Trails from dbo.TrailToCategories to dbo.Trails*/
Alter Table dbo.TrailToCategories add constraint FK_TrailToCategories_Trails foreign key (TrailID) references dbo.Trails (TrailID);
go
/*Foreign key FK_Videos_Accounts from dbo.Videos to dbo.Accounts*/
Alter Table dbo.Videos add constraint FK_Videos_Accounts foreign key (AccountID) references dbo.Accounts (AccountID);
go
/*Foreign key FK_VideoToCategories_Accounts from dbo.VideoToCategories to dbo.Accounts*/
Alter Table dbo.VideoToCategories add constraint FK_VideoToCategories_Accounts foreign key (AccountID) references dbo.Accounts (AccountID);
go
/*Foreign key FK_VideoToCategories_Categories from dbo.VideoToCategories to dbo.Categories*/
Alter Table dbo.VideoToCategories add constraint FK_VideoToCategories_Categories foreign key (CategoryID) references dbo.Categories (CategoryID);
go
/*Foreign key FK_VideoToCategories_Videos from dbo.VideoToCategories to dbo.Videos*/
Alter Table dbo.VideoToCategories add constraint FK_VideoToCategories_Videos foreign key (VideoID) references dbo.Videos (VideoID);
go
